********************************************************************************
* Exporting table for multi-country COVID paper (BGD5 sample)
* last updated: 2020-10-12
* Salim Benhachmi
********************************************************************************

clear all
use "$da/BGD5", clear

********************************************************************************

* SES Status
sum hh_inc, detail
gen higher_ses = (hh_inc >= `r(p50)')
gen lower_ses = (hh_inc < `r(p50)')

gen full_sample = 1

********************************************************************************

* Drop in employment
* N/A

* Drop in income
gen drop_inc = (hh_inc > ec_q24_b) if hh_inc != . & ec_q24_b != . 

* Reduced access to markets
gen mkts_clsd = (ec_q2_buying_3 == 1)

* Healthcareaccess delayed
* N/A

* Missed or reduced meals
gen fd_ins = (ec_q5a != 1 | ec_q5b != 1)

* Received NGO or Government Support
gen ngo_gov_sprt = (ec_q8_1 == 1)

********************************************************************************

keep if covid_sample == 1

local subgroups higher_ses lower_ses full_sample
local indicators drop_inc mkts_clsd fd_ins ngo_gov_sprt

foreach subgroup of local subgroups {
	
	foreach ind of local indicators {
			
		sum `ind' if `subgroup' == 1
		loc mean_`ind'_`subgroup' : di %10.2fc r(mean)
	}
}

sum covid_sample if higher_ses == 1
loc mean_n_higher_ses :  di %10.0fc r(N)
sum covid_sample if lower_ses == 1
loc mean_n_lower_ses :  di %10.0fc r(N)
sum covid_sample if full_sample == 1
loc mean_n_full_sample :  di %10.0fc r(N)

clear
set obs 3

local indicators drop_inc mkts_clsd fd_ins ngo_gov_sprt n

foreach ind of local indicators {	
	gen mean_`ind' = ""
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_full_sample'" in 1
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_lower_ses'" in 2
}

foreach ind of local indicators {	
	replace mean_`ind' = "`mean_`ind'_higher_ses'" in 3
}

gen mean_drop_empl = ""
gen mean_hlth_care_denied = ""

order mean_drop_inc mean_drop_empl mean_mkts_clsd mean_hlth_care_denied ///
	mean_fd_ins mean_ngo_gov_sprt mean_n

export excel using "$dtab/Main Table.xlsx", sheetmodify cell(B18)

********************************************************************************
